#-*- coding: utf8 -*-
from tutor.script import *
from tutor.plugin.maple import *

# variáveis úteis
half = M('1/2')
t = M.t
_i, _j, _k = M('_i, _j, _k')
rr = M('`..`')

# parâmetros iniciais
a, lambd = map(M, oneof(
    (2, 3*half),
    (3*half, 2),
    (half, 3*half),
    (2, 2)
))
k = oneof(1, 3, 4, 9) * oneof(-1, 1) / M(2)
t0, t1 = 0, 2 * M.Pi

# ATENCAO! --- prova ------------- --------------------------------------------
a, lambd = M(3)/2, M(2)
k = M(3)/2

# funções relacionadas ao caminho
X = a * (sin(t) - t*cos(t))
Y = a * (cos(t) + t*sin(t))
Z = k * t**2
Vx, Vy, Vz = ( M.diff(f, t) for f in [X, Y, Z] )
v = M.simplify(M.sqrt(Vx**2 + Vy**2 + Vz**2))
vNZ = M.simplify(M.sqrt(Vx**2 + Vy**2))
print('variáveis: \n\tR=(%s, %s, %s)\n\tV=(%s, %s, %s)\n\tt0=%s, t1=%s' 
       % (X, Y, Z, Vx, Vy, Vz, t0, t1))

# respostas, massa
mass = M.int(v * lambd, t=rr(t0, t1))
massND = mass / lambd
massNZ = M.int(vNZ * lambd, t=rr(t0, t1))
massFlat = M.abs(M.int(Vx + Vy + Vz, t=rr(t0, t1)) * lambd)
print('massa: %s\ndistratores: %s, %s, %s' % (mass, massND, massNZ, massFlat))

# respostas, inércia
d2 = M.simplify(X**2 + Y**2)
print('d2: %s' % d2)
Iz = M.int(v * lambd * d2, t=rr(t0, t1))
IzND = Iz / lambd
IzNZ = M.int(vNZ * lambd * d2, t=rr(t0, t1))
IzFlat = M.abs(M.int((Vx + Vy + Vz) * d2, t=rr(t0, t1)) * lambd)
IzV = M.int(v * lambd * M.simplify(Vx**2 + Vy**2), t=rr(t0, t1))
print('Iz: %s\ndistratores: %s, %s, %s, %s' % (Iz, IzND, IzNZ, IzFlat, IzV))
